package cn.itsource.controller.app;


import cn.itsource.pojo.ro.DriverOnLineRo;
import cn.itsource.pojo.ro.GeoRo;
import cn.itsource.pojo.ro.WxChatRegisterRo;
import cn.itsource.result.JSONResult;
import cn.itsource.service.IDriverService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "司机对象",description = "司机对象")
@RestController
@RequestMapping("/app/driver")
public class AppDriverController {
    @Autowired
    private IDriverService driverService;

    @Operation( summary= "注册Driver",description = "基础对象WX注册接口")
    @Parameter(name = "",description = "请求的参数",required = true)
    @PostMapping
    //需要接受一个code 从前端传过来
    public JSONResult wxChatRegister(@RequestBody @Valid WxChatRegisterRo registerRo){
        return driverService.wxChatRegister(registerRo);
    }
    @Operation( summary= "司机接单的时候",description = "基础对象WX注册接口")
    @Parameter(name = "",description = "请求的参数",required = true)
    @PostMapping("/onLine")
    public JSONResult driverOnLine(@RequestBody @Valid DriverOnLineRo onLineRo){
        return JSONResult.success(driverService.driverOnLine(onLineRo));
    }
    @Operation( summary= "司机停止接单的时候",description = "基础对象WX注册接口")
    @Parameter(name = "",description = "请求的参数",required = true)
    @PostMapping("/offLine")
    public JSONResult driverOffLine(){
        driverService.driverOffLine();
        return JSONResult.success();
    }
    @Operation( summary= "司机坐标实时更新",description = "基础对象WX注册接口")
    @Parameter(name = "",description = "请求的参数",required = true)
    @PostMapping("/geo")
    public JSONResult geo(@RequestBody @Valid GeoRo geoRo){
        driverService.geo(geoRo);
        return JSONResult.success();
    }

    /**
     * 获取当前司机接收到的订单
     * @return
     */
    @Operation( summary= "获取司机当前收到订单",description = "基础对象WX注册接口")
    @Parameter(name = "",description = "请求的参数",required = true)
    @GetMapping("/pullOrderForDriver")
    public JSONResult pullOrderForDriver(){
        return JSONResult.success(driverService.pullOrderForDriver());
    }


}
